package org.poem;

import org.poem.api.ListService;
import org.poem.condition.LinuxCondition;
import org.poem.condition.WindowsCondition;
import org.poem.service.LinuxService;
import org.poem.service.WindowService;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;

/**
 * Created by poem on 2017/8/29.
 */
@SpringBootApplication
public class Main {

    @Bean
    @Conditional(WindowsCondition.class)
    public ListService windowsListService(){
        return  new WindowService();
    }

    @Bean
    @Conditional(LinuxCondition.class)
    public ListService linuxListService(){
        return  new LinuxService();
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext(Main.class);
        ListService service = configApplicationContext.getBean(ListService.class);
        System.err.println(configApplicationContext.getEnvironment().getProperty("os.name")+"系统下的命令为："+ service.showListCmd());
    }
}
